<template>
  <div>
    <van-cell-group title="多条折线图">
      <div id="myChart" ref="myChart" />
    </van-cell-group>
  </div>
</template>

<script>
export default {
  data() {
    return {
      chart: null,
      options: {}
    };
  },
  mounted() {
    this.initOptions();
    this.initCharts();
  },
  methods: {
    initOptions() {
      this.options = {
        title: {
        },
        tooltip: {
          trigger: 'axis'
        },
        grid: {
          left: '3%',
          right: '4%',
          bottom: '3%',
          containLabel: true
        },
        xAxis: {
          type: 'category',
          boundaryGap: false,
          data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
        },
        yAxis: {
          type: 'value'
        },
        series: [
          {
            name: 'Email',
            type: 'line',
            stack: 'Total',
            data: [220, 182, 191, 304, 290, 430, 510]
          },
          {
            name: 'Search Engine',
            type: 'line',
            stack: 'Total',
            data: [120, 232, 301, 434, 590, 730, 820]
          }
        ]
      };
    },
    initCharts() {
      this.chart = this.$echarts.init(this.$refs.myChart);
      this.chart.setOption(this.options);
    }
  }
};
</script>

<style scoped>
#myChart {
  width: 100%;
  height: 280px;
}
</style>
